package com.flycms.module.soft.service;

import com.flycms.core.entity.PageVo;
import com.flycms.module.soft.dao.SoftCategoryDao;
import com.flycms.module.soft.model.Soft;
import com.flycms.module.soft.model.SoftCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author huangzt
 * @version 1.0
 * @date 2020/3/7 17:08
 */
@Service
public class SoftCategoryService {
    @Autowired
    SoftCategoryDao softCategoryDao;

    public int insert(SoftCategory softCategory){
       return softCategoryDao.insert(softCategory);
    }

    public int update(SoftCategory softCategory){
        return softCategoryDao.update(softCategory);
    }

    public SoftCategory queryByPk(Integer id){
        return softCategoryDao.queryByPk(id);
    }

    public int delete(Integer id){
        return softCategoryDao.delete(id);
    }

    public PageVo<SoftCategory> queryByPage(String category_name, String orderby, String order, Integer pageIndex, Integer pageSzie){
        if(orderby==null){
            orderby="update_time";
        }
        if(order==null){
            order="desc";
        }
        PageVo pageVo = new PageVo(pageIndex);
        pageVo.setRows(pageSzie);
        pageVo.setList(softCategoryDao.queryByPage(category_name,orderby,order,pageVo.getOffset(),pageVo.getRows()));
        pageVo.setCount(softCategoryDao.countCategory(category_name));
        return pageVo;
    }
}
